package com.zjj.lbw.microservice.seata.storage.seatastorageservice.controller;

import com.zjj.lbw.microservice.seata.storage.seatastorageservice.service.StorageService;
import com.zjj.lbw.microservice.seata.storage.seatastorageservice.service.TCCStorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhanglei.zjj
 */
@RestController
@RequestMapping("/storage")
public class StorageController {

    @Autowired
    private StorageService storageService;

    @Autowired
    private TCCStorageService tccStorageService;

    @RequestMapping(path = "/deduct")
    public Boolean deduct(String commodityCode, Integer count) {
        // 扣减库存
        storageService.deduct(commodityCode, count);
        return true;
    }

    @RequestMapping(path = "/tcc/deduct")
    public Boolean tccDeduct(String commodityCode, Integer count) {
        // 扣减库存
        tccStorageService.deduct(commodityCode, count);
        return true;
    }
}
